/**
 * 获取当前的日期时间 格式“yyyy-MM-dd HH:MM:SS”
 * @export
 * @returns currentdate
 */

export default function computeTime(key) {
    var date = new Date();
    var seperator1 = "-";
    var seperator2 = ":";
    var year = date.getFullYear(); // 年
    var month = date.getMonth() + 1; // 月
    var strDate = date.getDate(); // 日 
    var Hours = date.getHours();// 小时
    var Minutes = date.getMinutes();  // 分
    var Seconds = date.getSeconds(); // 秒
    var week = date.getDay(); // 星期
    var currentdate = ''; // 当前时间
    var strWeek = ''; // 星期几
    if (week == 0) {
        strWeek = "星期日";
    } else if (week == 1) {
        strWeek = "星期一";
    } else if (week == 2) {
        strWeek = "星期二";
    } else if (week == 3) {
        strWeek = "星期三";
    } else if (week == 4) {
        strWeek = "星期四";
    } else if (week == 5) {
        strWeek = "星期五";
    } else if (week == 6) {
        strWeek = "星期六";
    }
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    if (Hours >= 0 && Hours <= 9) {
        Hours = '0' + Hours
    }
    if (Minutes >= 0 && Minutes <= 9) {
        Minutes = '0' + Minutes
    }
    if (Seconds >= 0 && Seconds <= 9) {
        Seconds = '0' + Seconds
    }


    switch (key) {
        case 'time':
            currentdate = year + seperator1 + month + seperator1 + strDate
                + " " + Hours + seperator2 + Minutes + seperator2 + Seconds;
            return currentdate;
        case 'miniTime':
            currentdate = Hours + seperator2 + Minutes;
            return currentdate;
        case 'date':
            currentdate = year + '年' + month + '月' + strDate +'日';
            return currentdate;
        case 'week':
            currentdate = strWeek;
            return currentdate;
        default:
            break;
    }
}
